import java.io.*;
import java.util.List;

import project3.Algorithms;

import suffiztreegenerators.McCreights;
import tandemrepeats.SimpleAlgorithms;
import tree.Tree;

public class Main {
	private static String inputString;
	private static String patternString;
	private static Tree tree;

	public static void main(String[] args) {
		if(args.length == 3) {
			if(!(new File(args[0]).exists())) {
				System.err.println("File does not exist");
				return;
			}
			inputString = fileToString(new File(args[0]));
			patternString = args[1];
			
			if(args[2].equals("kmp")) {
				Algorithms.kmp(inputString, patternString);
			} else if(args[2].equals("bm")) {
				Algorithms.bm(inputString, patternString);
			}
			
		} else {
			System.out.println("Parameters: [filename] [pattern] [algorithm:{kmp,bm}]");
			return;
		}
		/*tree = new McCreights().generateSuffixTree(inputString);

		SimpleAlgorithms.findTandems(tree);*/
		
		//Algorithms.kmp(inputString, patternString);
		//Algorithms.bm(inputString, patternString);
	}
	
	public static String fileToString(File file) {
		String content = "";
		BufferedReader reader = null;
		
		try {
			reader = new BufferedReader(new FileReader(file));
			int i;
			while((i = reader.read()) != -1) {
				content += (char) i;
			}
			reader.close();
		} catch(Exception e) {
			e.printStackTrace();
		}
		return content;
	}
}
